package com.minova.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.minova.demo.entity.TzProd;
import com.minova.demo.entity.TzProdComm;
import com.minova.demo.service.ITzProdCommService;
import com.minova.demo.service.ITzProdService;

@RestController
@RequestMapping("com/minova/demo/ProdDetailOrIndex")
public class TzProdController {
	@Autowired
	private ITzProdService prod;
	
	@Autowired
	private ITzProdCommService prodComm;
	
	/**
	 * 分页查询
	 * 
	 * @param prod_name 商品名
	 * @param category_id 商品分类
	 * @param page 页数
	 * @param size 每页数据数
	 * @return
	 */
	@RequestMapping("listTzProd")
	public IPage<TzProd> listTzProd(String prod_name, String column, String column_id, int page, int size,String byDesc){
		return prod.selectPageVo(prod_name,column, column_id, page, size,byDesc );
	}
	
	@RequestMapping("listProdDetailFatch")
	public TzProd listProdFatch(Integer sTzProdID) {
		return prod.selectTzProd(sTzProdID);
	}
	
	@RequestMapping("listProdCommPage")
	public IPage<TzProdComm> listProdCommPage(Integer evaluate){
		Page<TzProdComm> page = new Page<>(0,4);
		Wrapper<TzProdComm> weapper = new QueryWrapper<>();
		((QueryWrapper<TzProdComm>) weapper).eq("evaluate", evaluate);
		
		return prodComm.page(page, weapper);
	}
	
}
